﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="NewItemEdit.aspx.cs" Inherits="Main_Item_NewItemEdit"
    Culture="en-GB" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="AjaxControl" %>
<%@ Register Src="~/User Controls/PageHeading.ascx" TagName="heading" TagPrefix="acc" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>Untitled Page</title>
    <link href="../../../Styles/accounts.css" rel="Stylesheet" type="text/css" />
    <script src="../../../JavaScript/Commons.js" type="text/javascript"></script>
    <script type="text/javascript" language="javascript">
        function showMsg() {
            alert(document.getElementById('TxtItemCode').value + ' Item Updated');
            window.location = "Item.aspx?action=view";
        }
        function Validate() {
            var status = new Boolean(false);
            var Count = document.getElementById("hidControl").value;
            for (var i = 1; i <= Count; i++) {
                var dropdown = document.getElementById("DDLLocation" + i);
                var ddlvalue = dropdown.options[dropdown.selectedIndex].value;

                if (ddlvalue != "0") {
                    status = true;
                    var qtyval = document.getElementById("TxtQty" + i).value;
                    var rateval = document.getElementById("TxtRate" + i).value;
                    if (qtyval == '' || rateval == '' || qtyval == 0 || rateval == 0) {
                        alert("Quantity or Rate Cannot be null");
                    }

                    break;

                }
            }

            if (status == true) {
                return CheckDuplicateLocationBatch();

            }
            else {
                alert("Please Select atleast One Location");
                return false;
            }
        }


        function CheckDuplicateLocationBatch() {
            var Count = document.getElementById("hidControl").value;
            for (var i = 1; i <= Count; i++) {
                var dropdown = document.getElementById("DDLLocation" + i);
                var ddlvalue = dropdown.options[dropdown.selectedIndex].value;
                var Textvalue = document.getElementById("TxtBatch" + i).value;
                if (ddlvalue != '0' && Textvalue != "") {
                    for (var j = 1; j <= Count; j++) {
                        if (j != i) {
                            var dropdown1 = document.getElementById("DDLLocation" + j);
                            var ddlvalue1 = dropdown1.options[dropdown1.selectedIndex].value;
                            var Textvalue1 = document.getElementById("TxtBatch" + j).value;
                            if (ddlvalue == ddlvalue1 && Textvalue == Textvalue1) {
                                alert("Duplicate location and batch No.");
                                return false;
                                break;
                            }
                        }
                    }
                }
            }
            return true;
        }

        function calcQty() {
            var Count = document.getElementById("hidControl").value;
            var totqty = 0;
            var totvalue = 0;
            for (var i = 1; i <= 2; i++) {
                var qty = 0;

                if (document.getElementById("TxtQty" + i).value != '') {
                    qty = eval(document.getElementById("TxtQty" + i).value);
                }
                var rate = 0;
                if (document.getElementById("TxtRate" + i).value != '') {
                    rate = eval(document.getElementById("TxtRate" + i).value);
                }

                var totalvalue = qty * rate;
                document.getElementById("TxtValue" + i).value = totalvalue;

                totqty += qty;
                totvalue += totalvalue;
            }
            document.getElementById("TxtTotal").value = totqty;
            document.getElementById("TxtTotal1").value = totvalue;
        }
        function MaximumOrMinimum(id) {
            if (document.getElementById(id).value == '') {
                document.getElementById(id).value = "0.00";
            }
            //            var TxtMaximum = document.getElementById("TxtMaximum");
            //            var TxtMiniMum = document.getElementById("TxtMinimum");
            //            var condition = TxtMaximum != TxtMiniMum || TxtMaximum > TxtMiniMum;
            //            document.getElementById("condition").value;
        }
        function CalculateAmount() {
            var totalOpeningStock = 0.0;
            if (document.getElementById("txtratemain").value != '') {
                rate = document.getElementById("txtratemain").value;
            }
            if (document.getElementById("txtqtymain").value != '') {
                qty = document.getElementById("txtqtymain").value;
            }
            tempvalue = parseFloat(rate) * parseFloat(qty);
            document.getElementById("txtvaluerateqtymain").value = tempvalue.toFixed(2);
            totalOpeningStock = parseFloat(totalOpeningStock) + parseFloat(tempvalue);
            document.getElementById("hidTotalOp").value = totalOpeningStock;
        }
        function calcLeadTime() {
            var MFRLeadTime = 0;
            var TransitLeadTime = 0;
            var TotalLeadTime = 0;
            for (var i = 1; i < tblMPN.rows.length; i++) {
                if (document.getElementById("txtmfrleadtime" + i).value != '' && document.getElementById("txttransitleadtime" + i).value != '') {
                    document.getElementById("txttotalleadtime" + i).value = parseFloat(document.getElementById("txtmfrleadtime" + i).value) + parseFloat(document.getElementById("txttransitleadtime" + i).value);
                }
            }
        }
    </script>
    <style type="text/css">
        .hover
        {
            position: relative;
        }
        .tooltip
        {
            top: -20px;
            background-color: #88BD6E;
            color: white;
            opacity: 0;
            text-align: center;
            padding: 5px;
            position: absolute;
            -webkit-transition: all 0.5s;
            -moz-transition: all 0.5s;
            -ms-transition: all 0.5s;
            -o-transition: all 0.5s;
            transition: all 0.5s;
            visibility: hidden;
        }
        .hover:hover .tooltip
        {
            opacity: 1;
            visibility: visible;
        }
        #Background
        {
            position: fixed;
            top: 0px;
            bottom: 0px;
            left: 0px;
            right: 0px;
            background-color: #E8EAEC;
            opacity: 0.5;
        }
        #Progress
        {
            position: fixed;
            top: 45%;
            margin-left: 350px;
            width: 300px;
            height: 50px;
            text-align: center;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true" EnablePartialRendering="true">
        </asp:ScriptManager>
        <div class="divmain">
            <acc:heading ID="pagehead" runat="server" HeadingText="Item Master -> Edit" />
        </div>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <div align="center">
                    <asp:Label ID="LblMsg" runat="server" Font-Bold="true"></asp:Label></div>
                <asp:UpdateProgress DynamicLayout="false" AssociatedUpdatePanelID="UpdatePanel2"
                    ID="UpdProgress" runat="server">
                    <ProgressTemplate>
                        <div align="center">
                            <img src="../../../Images/ajax-loader.gif" /></div>
                    </ProgressTemplate>
                </asp:UpdateProgress>
                <div style="width: 90%; margin-left: 5%; margin-right: 5%;">
                    <asp:HiddenField ID="hidControl" Value="4" runat="server" />
                    <table class="tablecontent" style="width: 100%">
                        <tr>
                            <td class="headtd" colspan="5">
                                Item Details
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Item Code <span class="required">*</span>
                            </td>
                            <td>
                                <asp:TextBox ID="TxtItemCode" runat="server" Width="200px" ToolTip="Enter Item Code"
                                    CssClass="input" MaxLength="25"></asp:TextBox>
                                <asp:RequiredFieldValidator ID="RFVItemCode" runat="server" ControlToValidate="TxtItemCode"
                                    ErrorMessage="*"></asp:RequiredFieldValidator>
                            </td>
                            <td>
                                Item Name <span class="required">*</span>
                            </td>
                            <td>
                                <asp:TextBox ID="TxtItemDescription" runat="server" ToolTip="Enter Item Name" Width="200px"
                                    CssClass="input" MaxLength="100" AutoPostBack="true" OnTextChanged="TxtItemDescription_TextChanged"></asp:TextBox>
                                <asp:RequiredFieldValidator ID="RFVItemDescription" runat="server" ControlToValidate="TxtItemDescription"
                                    ErrorMessage="*"></asp:RequiredFieldValidator>
                                <script type="text/javascript">
                                    function CheckItemName() {
                                        alert("Entered Item Name is already Exists.");
                                        document.getElementById("TxtItemDescription").value = "";
                                        document.getElementById("TxtItemDescription").focus();
                                        return false;
                                    }</script>
                            </td>
                            <td rowspan="6" width="20%">
                                <asp:Image ID="Photo" runat="server" Height="75px" Width="100px" />
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Alternate Desc.
                            </td>
                            <td>
                                <asp:TextBox ID="TxtAlternateDesc" runat="server" ToolTip="Enter Alternate Desc."
                                    Width="200px" CssClass="input" MaxLength="100"></asp:TextBox>
                            </td>
                            <td>
                                Additional Desc.
                            </td>
                            <td valign="top">
                                <asp:TextBox ID="TxtAdditionalDesc" runat="server" Height="20px" ToolTip="Enter Additional Desc."
                                    Width="200px" CssClass="input" MaxLength="100"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Item Group <span class="required">*</span>
                            </td>
                            <td>
                                <asp:DropDownList ID="DDLItemGroup" runat="server" CssClass="dropdown" Width="203px">
                                </asp:DropDownList>
                                <asp:RequiredFieldValidator ID="RFVItemGroup" runat="server" ControlToValidate="DDLItemGroup"
                                    ErrorMessage="*"></asp:RequiredFieldValidator>
                            </td>
                            <td>
                                Category
                            </td>
                            <td>
                                <asp:DropDownList ID="DDLCategory" runat="server" CssClass="dropdown" Width="203px">
                                </asp:DropDownList>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                UOM <span class="required">*</span>
                            </td>
                            <td>
                                <asp:DropDownList ID="DDLPrimaryUnit" runat="server" CssClass="dropdown" Width="203px"
                                    AutoPostBack="true" OnSelectedIndexChanged="DDLPrimaryUnit_SelectedIndexChanged">
                                </asp:DropDownList>
                                <asp:RequiredFieldValidator ID="RFVPrimaryUnit" runat="server" ControlToValidate="DDLPrimaryUnit"
                                    ErrorMessage="*"></asp:RequiredFieldValidator>
                            </td>
                            <td>
                                Alternate Units for Item
                            </td>
                            <td>
                                <asp:DropDownList ID="DdlAltUnit" runat="server" Width="203px" CssClass="dropdown"
                                    AutoPostBack="true">
                                </asp:DropDownList>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                location Id
                            </td>
                            <td>
                                <asp:TextBox ID="txtlocationid" CssClass="input" TabIndex="9" runat="server" ToolTip="Enter bin location id"
                                    Width="200px"></asp:TextBox>
                            </td>
                            <td>
                                Bill Reference<span class="required">*</span>
                            </td>
                            <td>
                                <asp:TextBox ID="TxtBillRef" runat="server" CssClass="input" Width="200px" ToolTip="Enter Bill Ref"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Project Name <span class="required">*</span>
                            </td>
                            <td>
                                <asp:DropDownList ID="ddlproject" runat="server" CssClass="dropdown" Width="203px"
                                    ToolTip="Enter Project">
                                </asp:DropDownList>
                            </td>
                            <td>
                                Stock Type <span class="required">*</span>
                            </td>
                            <td>
                                <asp:DropDownList ID="DDLStockType" runat="server" CssClass="dropdown" Width="203px">
                                </asp:DropDownList>
                                <asp:RequiredFieldValidator ID="RFVStockType" runat="server" ControlToValidate="DDLStockType"
                                    ErrorMessage="*"></asp:RequiredFieldValidator>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Leased Type<span class="required">*</span>
                            </td>
                            <td>
                                <asp:DropDownList ID="ddlLeasedType" runat="server" CssClass="dropdown" Width="203px">
                                    <asp:ListItem Text="-- Select Leased Type --" Value="0"></asp:ListItem>
                                    <asp:ListItem Text="Owned" Value="1"></asp:ListItem>
                                    <asp:ListItem Text="Consigned" Value="2"></asp:ListItem>
                                </asp:DropDownList>
                            </td>
                            <td style="vertical-align: top; padding-top: 15px;">
                                Photo Image
                            </td>
                            <td style="padding-top: 15px;">
                                <asp:FileUpload ID="fld" runat="server" />
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Re-Order
                            </td>
                            <td>
                                <asp:TextBox ID="TxtReorder" runat="server" Width="150px" CssClass="input" MaxLength="10"
                                    onKeyPress="return isNumberKey(this.id,event)" Text="0.00" ToolTip="Maximum"
                                    onfocus="if(this.value=='0.00') this.value='';" onblur="MaximumOrMinimum(this.id);"></asp:TextBox>
                            </td>
                            <td>
                                <asp:CheckBox ID="ChkActive" runat="server" Text="Active" />
                            </td>
                            <td>
                            </td>
                        </tr>
                        <tr style="display: none;">
                            <td colspan="4" style="margin: 0; width: 100%;">
                                <%--<table style="width: 100%;">
                                        <tr>
                                            <td class="headtd" style="font-weight: bold; border-top: 1px solid #818181;
                                                padding: 0; margin: 0;">
                                                
                                            </td>
                                            <td class="headtd" style="font-weight: bold; border-top: 1px solid #818181;
                                                padding: 0; margin: 0;">
                                                Dimensional and Weight</td>
                                        </tr>
                                    </table>--%>
                                <table style="width: 100%; margin-top: 5px; margin-bottom: 5px;">
                                    <tr>
                                        <td colspan="3" class="headtd" style="font-weight: bold; border-top: 1px solid #818181;
                                            padding: 0; margin: 0;">
                                            Quantity Level
                                        </td>
                                        <td colspan="2" class="headtd" style="display: none; font-weight: bold; border-top: 1px solid #818181;
                                            padding: 0; margin: 0;">
                                            Dimensional and Weight
                                        </td>
                                    </tr>
                                    <tr style="display: none;">
                                        <td style="width: 17%;">
                                            Maximum
                                        </td>
                                        <td style="width: 29%;">
                                            <asp:TextBox ID="TxtMaximum" runat="server" CssClass="input" MaxLength="10" onKeyPress="return isNumberKey(this.id,event)"
                                                onblur="MaximumOrMinimum(this.id);" Text="0.0" onfocus="if(this.value=='0.00') this.value='';"
                                                Width="150px" ToolTip="Maximum"></asp:TextBox>
                                        </td>
                                        <td style="width: 21%;">
                                            Dimension
                                        </td>
                                        <td>
                                            <asp:TextBox ID="TxtDimensional" runat="server" Width="150px" CssClass="input" MaxLength="20"
                                                onKeyPress="return isNumberKey(this.id,event)" Text="0.00" onfocus="if(this.value=='0.00') this.value='';"
                                                onblur="MaximumOrMinimum(this.id);" ToolTip="Dimension"></asp:TextBox>
                                        </td>
                                    </tr>
                                    <tr style="display: none;">
                                        <td>
                                            Minimum
                                        </td>
                                        <td>
                                            <asp:TextBox ID="TxtMinimum" runat="server" CssClass="input" Width="150px" MaxLength="10"
                                                onKeyPress="return isNumberKey(this.id,event)" onblur="MaximumOrMinimum(this.id);"
                                                onfocus="if(this.value=='0.00') this.value='';" Text="0.00" ToolTip="Maximum"></asp:TextBox>
                                        </td>
                                        <td>
                                            Weight
                                        </td>
                                        <td>
                                            <asp:TextBox ID="TxtWeight" runat="server" CssClass="input" Width="150px" MaxLength="10"
                                                onKeyPress="return isNumberKey(this.id,event)" Text="0.00" onfocus="if(this.value=='0.00') this.value='';"
                                                onblur="MaximumOrMinimum(this.id);" ToolTip="Weight"></asp:TextBox>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td style="width: 17%;">
                                            Re-Order
                                        </td>
                                        <td>
                                        </td>
                                        <td style="display: none;">
                                            Unit of Weight
                                        </td>
                                        <td style="display: none;">
                                            <asp:DropDownList ID="DdlUnitOfweight" runat="server" Width="153px" CssClass="dropdown"
                                                ToolTip=" Unit of Weight">
                                            </asp:DropDownList>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="5" style="padding: 0; margin: 0; width: 100%">
                                <table style="width: 100%;">
                                    <tr>
                                        <td style="background-color: #fbfbfb; font-weight: bold; border: 1px solid #818181;
                                            padding: 0; margin: 0;" class="headtd">
                                            Manufacturer Detail
                                        </td>
                                    </tr>
                                </table>
                                <%--Manufacturer Detail --%>
                                <table id="tblMPN" runat="server" style="width: 100%; margin-top: 5px; margin-bottom: 5px;">
                                    <tr>
                                        <td style="width: 19%;">
                                            Manufacturer Part No<%--<span class="required">*</span>--%>
                                        </td>
                                        <td style="width: 19%;">
                                            Manufacturer Name<%--<span class="required">*</span>--%>
                                        </td>
                                        <td style="width: 19%;">
                                            MFR Lead Time<%--<span class="required">*</span>  --%>
                                        </td>
                                        <td style="width: 19%;">
                                            Transit Lead Time<%--<span class="required">*</span>--%>
                                        </td>
                                        <td style="width: 19%;">
                                            Total Lead Time<%--<span class="required">*</span>--%>
                                        </td>
                                        <td style="width: 5%;">
                                            &nbsp;
                                        </td>
                                    </tr>
                                    <tr>
                                        <td style="width: 19%;">
                                            <asp:TextBox ID="txtmanufacturecode1" TabIndex="20" runat="server" Width="120px"
                                                CssClass="input" ToolTip="Enter Manufacturer Part No"></asp:TextBox>
                                        </td>
                                        <td style="width: 19%;">
                                            <asp:DropDownList ID="ddlManufacturer1" TabIndex="21" runat="server" Width="122px"
                                                CssClass="dropdown">
                                            </asp:DropDownList>
                                        </td>
                                        <td style="width: 19%;">
                                            <asp:TextBox ID="txtmfrleadtime1" TabIndex="22" runat="server" ToolTip="MFR Lead Time"
                                                CssClass="input" onkeypress="return isNumberKey(this.id,event)" onblur="calcLeadTime();"
                                                Width="120px"></asp:TextBox><span>(D)</span>
                                            <%--<asp:RequiredFieldValidator ID="RFVmfrleadtime" Display="Dynamic"
                                                    runat="server" ControlToValidate="txtmfrleadtime1" ErrorMessage="*"></asp:RequiredFieldValidator>--%>
                                        </td>
                                        <td style="width: 19%;">
                                            <asp:TextBox ID="txttransitleadtime1" runat="server" TabIndex="23" ToolTip="Transit Lead Time"
                                                CssClass="input" onkeypress="return isNumberKey(this.id,event)" onblur="calcLeadTime();"
                                                Width="120px"></asp:TextBox><span>(D)</span>
                                            <%--<asp:RequiredFieldValidator ID="RFVtransitleadtime" Display="Dynamic"
                                                    runat="server" ControlToValidate="txttransitleadtime1" ErrorMessage="*"></asp:RequiredFieldValidator>--%>
                                        </td>
                                        <td style="width: 19%;" colspan="2">
                                            <asp:TextBox ID="txttotalleadtime1" TabIndex="24" Style="background-color: lightgray;"
                                                runat="server" ToolTip="Total Lead Time" CssClass="input" onkeypress="return isNumberKey(this.id,event)"
                                                onblur="calcLeadTime();" ReadOnly="true" Width="120px"></asp:TextBox><span>(D)</span>
                                            <%-- <asp:RequiredFieldValidator ID="RFVTotalleadtime" Display="Dynamic"
                                                    runat="server" ControlToValidate="txttotalleadtime1" ErrorMessage="*"></asp:RequiredFieldValidator>--%>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td style="width: 19%;">
                                            <asp:TextBox ID="txtmanufacturecode2" TabIndex="20" runat="server" Width="120px"
                                                CssClass="input" ToolTip="Enter Manufacturer Part No"></asp:TextBox>
                                        </td>
                                        <td style="width: 19%;">
                                            <asp:DropDownList ID="ddlManufacturer2" TabIndex="21" runat="server" Width="122px"
                                                CssClass="dropdown">
                                            </asp:DropDownList>
                                        </td>
                                        <td style="width: 19%;">
                                            <asp:TextBox ID="txtmfrleadtime2" TabIndex="22" runat="server" ToolTip="MFR Lead Time"
                                                CssClass="input" onkeypress="return isNumberKey(this.id,event)" onblur="calcLeadTime();"
                                                Width="120px"></asp:TextBox><span>(D)</span>
                                            <%--<asp:RequiredFieldValidator ID="RequiredFieldValidator1" Display="Dynamic"
                                                    runat="server" ControlToValidate="txtmfrleadtime2" ErrorMessage="*"></asp:RequiredFieldValidator>--%>
                                        </td>
                                        <td style="width: 19%;">
                                            <asp:TextBox ID="txttransitleadtime2" runat="server" TabIndex="23" ToolTip="Transit Lead Time"
                                                CssClass="input" onkeypress="return isNumberKey(this.id,event)" onblur="calcLeadTime();"
                                                Width="120px"></asp:TextBox><span>(D)</span>
                                            <%--<asp:RequiredFieldValidator ID="RequiredFieldValidator2" Display="Dynamic"
                                                    runat="server" ControlToValidate="txttransitleadtime2" ErrorMessage="*"></asp:RequiredFieldValidator>--%>
                                        </td>
                                        <td style="width: 19%;" colspan="2">
                                            <asp:TextBox ID="txttotalleadtime2" TabIndex="24" Style="background-color: lightgray;"
                                                runat="server" ToolTip="Total Lead Time" CssClass="input" onkeypress="return isNumberKey(this.id,event)"
                                                onblur="calcLeadTime();" ReadOnly="true" Width="120px"></asp:TextBox><span>(D)</span>
                                            <%--<asp:RequiredFieldValidator ID="RequiredFieldValidator3" Display="Dynamic"
                                                    runat="server" ControlToValidate="txttotalleadtime2" ErrorMessage="*"></asp:RequiredFieldValidator>--%>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td style="width: 19%;">
                                            <asp:TextBox ID="txtmanufacturecode3" TabIndex="20" runat="server" Width="120px"
                                                CssClass="input" ToolTip="Enter Manufacturer Part No"></asp:TextBox>
                                        </td>
                                        <td style="width: 19%;">
                                            <asp:DropDownList ID="ddlManufacturer3" TabIndex="21" runat="server" Width="122px"
                                                CssClass="dropdown">
                                            </asp:DropDownList>
                                        </td>
                                        <td style="width: 19%;">
                                            <asp:TextBox ID="txtmfrleadtime3" TabIndex="22" runat="server" ToolTip="MFR Lead Time"
                                                CssClass="input" onkeypress="return isNumberKey(this.id,event)" onblur="calcLeadTime();"
                                                Width="120px"></asp:TextBox><span>(D)</span>
                                            <%--<asp:RequiredFieldValidator ID="RequiredFieldValidator4" Display="Dynamic"
                                                    runat="server" ControlToValidate="txtmfrleadtime3" ErrorMessage="*"></asp:RequiredFieldValidator>--%>
                                        </td>
                                        <td style="width: 19%;">
                                            <asp:TextBox ID="txttransitleadtime3" runat="server" TabIndex="23" ToolTip="Transit Lead Time"
                                                CssClass="input" onkeypress="return isNumberKey(this.id,event)" onblur="calcLeadTime();"
                                                Width="120px"></asp:TextBox><span>(D)</span>
                                            <%--<asp:RequiredFieldValidator ID="RequiredFieldValidator5" Display="Dynamic"
                                                    runat="server" ControlToValidate="txttransitleadtime3" ErrorMessage="*"></asp:RequiredFieldValidator>--%>
                                        </td>
                                        <td style="width: 19%;" colspan="2">
                                            <asp:TextBox ID="txttotalleadtime3" TabIndex="24" Style="background-color: lightgray;"
                                                runat="server" ToolTip="Total Lead Time" CssClass="input" onkeypress="return isNumberKey(this.id,event)"
                                                onblur="calcLeadTime();" ReadOnly="true" Width="120px"></asp:TextBox><span>(D)</span>
                                            <%-- <asp:RequiredFieldValidator ID="RequiredFieldValidator6" Display="Dynamic"
                                                    runat="server" ControlToValidate="txttotalleadtime3" ErrorMessage="*"></asp:RequiredFieldValidator>--%>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                        <asp:Panel ID="panmain" runat="server">
                            <tr>
                                <td colspan="5" style="padding: 0; margin: 0; width: 100%">
                                    <asp:HiddenField ID="hidsecond" Value="1" runat="server" />
                                    <table id="tbldisbatch" runat="server" style="width: 100%;">
                                        <tr>
                                            <td colspan="6" style="background-color: #fbfbfb; font-weight: bold; border: 1px solid #818181;
                                                padding: 0; margin: 0;" class="headtd">
                                                Opening Balance
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>
                                                Date
                                            </td>
                                            <td>
                                                Location
                                            </td>
                                            <td>
                                                Qty
                                            </td>
                                            <td>
                                                Rate
                                            </td>
                                            <td>
                                                Value
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>
                                                <asp:TextBox ID="txtopeningdate" runat="server" Enabled="false" Width="100px"></asp:TextBox>
                                                <asp:HiddenField ID="hidTotalOp" runat="server" />
                                            </td>
                                            <td>
                                                <asp:DropDownList ID="ddlloc" runat="server" Width="150px" onchange="return Getvalue(this.id);"
                                                    CssClass="dropdown">
                                                </asp:DropDownList>
                                                <asp:HiddenField ID="hidrowcount" runat="server" />
                                            </td>
                                            <td>
                                                <asp:TextBox ID="txtqtymain" runat="server" Width="140px" ToolTip="enter qty" onblur="return CalculateAmount();"
                                                    CssClass="input" onkeypress="return isNumberKey(this.id,event)"></asp:TextBox>
                                            </td>
                                            <td>
                                                <asp:TextBox ID="txtratemain" runat="server" Width="140px" ToolTip="enter rate" onblur="return CalculateAmount();"
                                                    CssClass="input" onkeypress="return isNumberKey(this.id,event)"></asp:TextBox>
                                            </td>
                                            <td>
                                                <asp:TextBox ID="txtvaluerateqtymain" runat="server" Width="140px" ToolTip="Total value"
                                                    CssClass="input" Enabled="false"></asp:TextBox>
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                        </asp:Panel>
                        <tr>
                            <td align="center" colspan="5">
                                <asp:UpdatePanel ID="UpdatePanel2" runat="server">
                                    <ContentTemplate>
                                        <asp:Button ID="Update" runat="server" Text="Update" CssClass="button" OnClick="Update_Click"
                                            OnClientClick="return validation();" />
                                        &nbsp;
                                        <script type="text/javascript">
                                            function validation() {
                                                if (document.getElementById("TxtItemCode").value == '') {
                                                    alert("Enter Item Code.");
                                                    document.getElementById("TxtItemCode").focus();
                                                    return false;
                                                }
                                                else if (document.getElementById("TxtItemDescription").value == '') {
                                                    alert(" Enter Item Name.");
                                                    document.getElementById("TxtItemDescription").focus();
                                                    return false;
                                                }
                                                else if (document.getElementById("DDLItemGroup").selectedIndex == 0) {
                                                    alert("Select Item Group.");
                                                    document.getElementById("DDLItemGroup").focus();
                                                    return false;
                                                }
                                                else if (document.getElementById("DDLPrimaryUnit").selectedIndex == 0) {
                                                    alert("Select U O M.");
                                                    document.getElementById("DDLPrimaryUnit").focus();
                                                    return false;
                                                }
                                                else if (document.getElementById("DDLStockType").selectedIndex == 0) {
                                                    alert("Select Stock Type.");
                                                    document.getElementById("DDLStockType").focus();
                                                    return false;
                                                }
                                                else if (document.getElementById("ddlproject").selectedIndex == 0) {
                                                    alert("Select Project Name.");
                                                    document.getElementById("ddlproject").focus();
                                                    return false;
                                                }
                                                else if (document.getElementById("ddlLeasedType").selectedIndex == 0) {
                                                    alert("Select Leased type.");
                                                    document.getElementById("ddlLeasedType").focus();
                                                    return false;
                                                }
                                                else if (document.getElementById("TxtBillRef").value == '') {
                                                    alert("Please Enter Bin Reference.");
                                                    document.getElementById("TxtBillRef").focus();
                                                    return false;
                                                }
                                                else if (document.getElementById("txtqtymain").value == '') {
                                                    alert("Please Enter Quantity.");
                                                    document.getElementById("txtqtymain").focus();
                                                    return false;
                                                }
                                                else if (document.getElementById("txtratemain").value == '') {
                                                    alert("Please Enter Rate.");
                                                    document.getElementById("txtratemain").focus();
                                                    return false;
                                                }
                                                else {
                                                    return true;
                                                }
                                            }
                                        </script>
                                        <asp:Button ID="Close" runat="server" Text="Close" CssClass="button" CausesValidation="false"
                                            OnClick="Close_Click" />
                                    </ContentTemplate>
                                </asp:UpdatePanel>
                            </td>
                        </tr>
                    </table>
                </div>
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
    </form>
</body>
</html>
